package com.ruoyi.web.controller.compensationManagement;

import java.math.BigDecimal;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.compensationManagement.domain.CompensationSalarySetting;
import com.ruoyi.compensationManagement.service.ICompensationSalarySettingService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 薪级薪资设置Controller
 * 
 * @author ruoyi
 * @date 2022-10-05
 */
@RestController
@RequestMapping("/compensationManagement/saralySettings")
public class CompensationSalarySettingController extends BaseController
{
    @Autowired
    private ICompensationSalarySettingService compensationSalarySettingService;

    /**
     * 查询薪级薪资设置列表
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:list')")
    @GetMapping("/list")
    public AjaxResult list(CompensationSalarySetting compensationSalarySetting)
    {
        List<CompensationSalarySetting> list = compensationSalarySettingService.selectCompensationSalarySettingList(compensationSalarySetting);
        return AjaxResult.success(list);
    }

    /**
     * 导出薪级薪资设置列表
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:export')")
    @Log(title = "薪级薪资设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompensationSalarySetting compensationSalarySetting)
    {
        List<CompensationSalarySetting> list = compensationSalarySettingService.selectCompensationSalarySettingList(compensationSalarySetting);
        ExcelUtil<CompensationSalarySetting> util = new ExcelUtil<CompensationSalarySetting>(CompensationSalarySetting.class);
        util.exportExcel(response, list, "薪级薪资设置数据");
    }

    /**
     * 获取薪级薪资设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:query')")
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return AjaxResult.success(compensationSalarySettingService.selectCompensationSalarySettingByPayId(payId));
    }

    /**
     * 新增薪级薪资设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:add')")
    @Log(title = "薪级薪资设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompensationSalarySetting compensationSalarySetting)
    {
        return toAjax(compensationSalarySettingService.insertCompensationSalarySetting(compensationSalarySetting));
    }

    /**
     * 修改薪级薪资设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:edit')")
    @Log(title = "薪级薪资设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompensationSalarySetting compensationSalarySetting)
    {
        return toAjax(compensationSalarySettingService.updateCompensationSalarySetting(compensationSalarySetting));
    }

    /**
     * 删除薪级薪资设置
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:saralySettings:remove')")
    @Log(title = "薪级薪资设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payIds}")
    public AjaxResult remove(@PathVariable Long[] payIds)
    {
        return toAjax(compensationSalarySettingService.deleteCompensationSalarySettingByPayIds(payIds));
    }
}
